home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / s_to_z / uback / btest.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  4KB  |  150 lines

  1. unit Btest;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Ubackup, Feedback, ExtCtrls, VBXCtrl,
  8.   Gauge;
  9.  
  10. type
  11.   TTestBackup = class(TForm)
  12.     UBack: TUBackup;
  13.     GroupBox1: TGroupBox;
  14.     Prozent: TBiGauge;
  15.     Label1: TLabel;
  16.     FileInProgress: TLabel;
  17.     RestZeit: TLabel;
  18.     Status: TPanel;
  19.     GroupBox2: TGroupBox;
  20.     FilesToBackup: TMemo;
  21.     GroupBox3: TGroupBox;
  22.     BitBtn1: TBitBtn;
  23.     Destination: TEdit;
  24.     UseCompression: TCheckBox;
  25.     Filecount: TLabel;
  26.     Button1: TButton;
  27.     RestoreDestination: TEdit;
  28.     Label2: TLabel;
  29.     procedure BitBtn1Click(Sender: TObject);
  30.     procedure UBackPercent(Sender: TObject);
  31.     procedure UBackNextFile(Sender: TObject);
  32.     procedure BitBtn2Click(Sender: TObject);
  33.     procedure UBackStartFileScan(Sender: TObject);
  34.     procedure UBackFileFound(Sender: TObject);
  35.     procedure UBackNextDir(Sender: TObject);
  36.     procedure FormShow(Sender: TObject);
  37.     procedure UBackEndFileScan(Sender: TObject);
  38.     procedure UBackReady(Sender: TObject);
  39.     procedure Button1Click(Sender: TObject);
  40.   private
  41.     { Private-Deklarationen }
  42.   public
  43.     { Public-Deklarationen }
  44.     FileCounter : Longint;
  45.   end;
  46.  
  47. var
  48.   TestBackup: TTestBackup;
  49.  
  50. implementation
  51.  
  52. {$R *.DFM}
  53.  
  54. procedure TTestBackup.BitBtn1Click(Sender: TObject);
  55. var Ergebnis : Word;
  56.     i        : Word;
  57. begin
  58.    Screen.Cursor := crHourGlass;
  59.    Uback.Compression := UseCompression.Checked;
  60.    uback.backupon    := Destination.Text;
  61.    uback.FilesToBackup.Clear;
  62.    for i:=0 to FilesToBackup.Lines.Count-1 do
  63.    uback.FilesToBackup.Add(FilesToBackup.Lines[i]);
  64.    uback.Backup;
  65. end;
  66.  
  67. procedure TTestBackup.UBackPercent(Sender: TObject);
  68. begin
  69.    Application.ProcessMessages;
  70.    Restzeit.Caption := FormatDateTime('hh:nn.ss',uback.remainingtime);
  71.    Prozent.Value := uback.percent;
  72. end;
  73.  
  74. procedure TTestBackup.UBackNextFile(Sender: TObject);
  75. begin
  76.    FileInProgress.Caption := UBack.FileAtWork;
  77.    dec(FileCOunter);
  78.    FileCount.Caption := inttostr(FileCOunter)+ ' Files';
  79.    Application.ProcessMessages;
  80. end;
  81.  
  82. procedure TTestBackup.BitBtn2Click(Sender: TObject);
  83. var Ergebnis : Integer;
  84. begin
  85. end;
  86.  
  87. procedure TTestBackup.UBackStartFileScan(Sender: TObject);
  88. begin
  89.    FileCounter := 0;
  90.    Status.Caption := 'Scan for files to be backed up';
  91. end;
  92.  
  93. procedure TTestBackup.UBackFileFound(Sender: TObject);
  94. begin
  95.    inc(FileCounter);
  96.    FileCount.Caption := inttostr(FileCounter)+' Files';
  97.    Application.ProcessMessages;
  98. end;
  99.  
  100. procedure TTestBackup.UBackNextDir(Sender: TObject);
  101. begin
  102.    FileInProgress.Caption := TUBackup(Sender).FileAtWork;
  103.    Application.ProcessMessages;
  104. end;
  105.  
  106. procedure TTestBackup.FormShow(Sender: TObject);
  107. begin
  108.    Status.Caption  := 'Specify what to backup and where to backup';
  109.    Prozent.Value   := 0;
  110.    Restzeit.Caption:= '00:00.00';
  111.    FileCount.Caption := '0 File(s)';
  112.    FileCounter       := 0;
  113. end;
  114.  
  115. procedure TTestBackup.UBackEndFileScan(Sender: TObject);
  116. begin
  117.    Status.Caption := 'Selected files are being backed up';
  118. end;
  119.  
  120. procedure TTestBackup.UBackReady(Sender: TObject);
  121. begin
  122.    Status.Caption := 'Backup is ready';
  123.    uback.filestobackup.savetofile('c:\soll.tmp');
  124.    uback.filesinarchive.savetofile('c:\ist.tmp');
  125.    Screen.Cursor  := crDefault;
  126. end;
  127.  
  128. procedure TTestBackup.Button1Click(Sender: TObject);
  129. var d : TDateTime;
  130.     e : String;
  131.     ecd : Integer;
  132. begin
  133.    Screen.Cursor := crHourglass;
  134.    Status.Caption  := 'Restore starts...';
  135.    Prozent.Value   := 0;
  136.    Restzeit.Caption:= '00:00.00';
  137.    FileCount.Caption := '0 File(s)';
  138.    FileCounter       := 0;
  139.    Uback.Compression := UseCompression.Checked;
  140.    uback.backupon    := Destination.Text;
  141.    uback.redirectRestore := TRUE;
  142.    uback.restoreTo   := RestoreDestination.Text;
  143.    ecd := uback.restore;
  144.    Screen.Cursor := crDefault;
  145.    if ecd<>0 then MessageDlg('Restore completed with Errorcode '+inttostr(ecd),
  146.    mtError,[mbok],-1);
  147. end;
  148.  
  149. end.
  150.